package domain;

import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import util.PhysicalFeatureUtil;
import util.RegexUtil;
import util.PhysicalFeature.*;

public class ActorJob {

	private long ajid;
	private long uid;// deprecated-probably will be removed from the database
	private long mid;
	private int fromAge;
	private int female;
	private int height;
	private int weight;
	private String hairColor;
	private String eyeColor;
	private String skinColor;
	private String description;
	private Timestamp ts;
	private int count;

	private Map<User, Integer> applied;

	public ActorJob(long ajid, long uid, long mid, String hairColor,
			String eyeColor, String skinColor, int height, int weight,
			String description, int fromAge, Timestamp ts, int female, int count) {

		this.ajid = ajid;
		this.uid = uid;
		this.mid = mid;
		this.hairColor = hairColor;
		this.eyeColor = eyeColor;
		this.skinColor = skinColor;
		this.height = height;
		this.weight = weight;
		this.description = description;
		this.fromAge = fromAge;
		this.ts = ts;
		this.female = female;
		this.count = count;
	}

	public Map<User, Integer> getApplied() {
		return applied;
	}

	public void setApplied(Map<User, Integer> applied) {
		this.applied = applied;
	}

	public long getAjid() {
		return ajid;
	}

	public void setAjid(long ajid) {
		this.ajid = ajid;
	}

	public int getCount() {
		return count;
	}

	public void setCount(int count) {
		this.count = count;
	}

	public long getUid() {
		return uid;
	}

	public void setUid(long uid) {
		this.uid = uid;
	}

	public long getMid() {
		return mid;
	}

	public void setMid(long mid) {
		this.mid = mid;
	}

	public int getFromAge() {
		return fromAge;
	}

	public void setFromAge(int fromAge) {
		this.fromAge = fromAge;
	}

	public int getFemale() {
		return female;
	}

	public void setFemale(int female) {
		this.female = female;
	}

	public int getHeight() {
		return height;
	}

	public void setHeight(int height) {
		this.height = height;
	}

	public int getWeight() {
		return weight;
	}

	public void setWeight(int weight) {
		this.weight = weight;
	}

	public String getHairColor() {
		return hairColor;
	}

	public void setHairColor(String hairColor) {
		this.hairColor = hairColor;
	}

	public String getEyeColor() {
		return eyeColor;
	}

	public void setEyeColor(String eyeColor) {
		this.eyeColor = eyeColor;
	}

	public String getSkinColor() {
		return skinColor;
	}

	public void setSkinColor(String skinColor) {
		this.skinColor = skinColor;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public Timestamp getTs() {
		return ts;
	}

	public void setTs(Timestamp ts) {
		this.ts = ts;
	}

	public List<Skin> getSkins() {
		List<Skin> skins = new ArrayList<Skin>();
		String[] pieces = RegexUtil.splitDiyez(skinColor);
		for (String piece : pieces) {
			if (!RegexUtil.isNullOrEmpty(piece))
				skins.add(PhysicalFeatureUtil.getSkinBySkinName(piece));
		}
		return skins;
	}

	public List<Eyes> getEyes() {
		List<Eyes> skins = new ArrayList<Eyes>();
		String[] pieces = RegexUtil.splitDiyez(eyeColor);
		for (String piece : pieces) {
			if (!RegexUtil.isNullOrEmpty(piece))
				skins.add(PhysicalFeatureUtil.getEyesByEyesName(piece));
		}
		return skins;
	}

	public List<Hair> getHairs() {
		List<Hair> skins = new ArrayList<Hair>();
		String[] pieces = RegexUtil.splitDiyez(hairColor);
		for (String piece : pieces) {
			if (!RegexUtil.isNullOrEmpty(piece))
				skins.add(PhysicalFeatureUtil.getHairByHairName(piece));
		}
		return skins;
	}

	public List<Gender> getGenders() {
		List<Gender> genders = new ArrayList<Gender>();
		if (female == 0)
			genders.add(PhysicalFeatureUtil.getGenderByGenderName("male"));
		else if (female == 1)
			genders.add(PhysicalFeatureUtil.getGenderByGenderName("female"));
		else
			return PhysicalFeatureUtil.getGenders();
		return genders;
	}
}
